<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8" />
		<title></title>
		<script src="../js/vue.js" type="text/javascript" charset="utf-8"></script>
	</head>
	<body>
		<div id="test">
			<label>ID</label>
			<input type="text" value="mary" v-model="id" name="name"/>
			<label>country</label>
			<input type="text" value="china" v-model="country" name="country"/>
			<input type="button" @click="addnew" value="新增"/>
			
			<table>
				<thead>
					<th>
						ID
					</th>
					<th>
						country
					</th>
				</thead>
				<tbody>
					<!--v-bind:key绑定为一个整体-->
					<tr v-for="item in list" v-bind:key="item.id">
						<td>
							<input type="checkbox" />
						</td>
						<td>{{ item.id }}</td>
						<td>{{ item.country }}</td>
					</tr>
				</tbody>
			</table>
			
		</div>
		<script>
			var vue = new Vue({
				el:'#test',
				data:{
					id:"wzy",
					country:"test",
					list:[
						{
							"id":"wang",
							"country":"china",
						},
						{
							"id":"zhang",
							"country":"US",
						},
						{
							"id":"li",
							"country":"UK",
						}
					]
					
				},
				methods:{
					addnew(){
						this.list.unshift({
							"id":this.id,
							"country":this.country
						})
					}
				}
			})
		</script>
	</body>
</html>
